<?php

use yii\db\Migration;

class m180313_070025_alter_goods extends Migration
{
    private function createDbs(){
        $dbs = [];
        $dbs_info =\Yii::$app->params['db'];
        foreach($dbs_info as $k=>$v){
            $dbs[$k] = \Yii::createObject($v);
        }
        return $dbs;
    }
    public function safeUp()
    {
        $dbs = $this->createDbs();
        foreach ($dbs as $v) {
            $this->db = $v;
            $this->addColumn('{{%goods}}', 'is_update_price', $this->smallInteger(1)->defaultValue(0)->comment('是否修改价格（0否 1是）'));
            $this->addColumn('{{%goods_price}}', 'price', $this->decimal(10,2)->defaultValue(0)->comment('单节课次价格'));
        }

    }

    public function safeDown()
    {
        $dbs = $this->createDbs();
        foreach ($dbs as $v) {
            $this->db = $v;
            $this->dropColumn('{{%goods}}', 'is_update_price');
            $this->dropColumn('{{%goods_price}}', 'price');
        }
    }
}
